package java0710test05;

import java.util.Scanner;

public class Gardener {
	//水果
	static Fruit[] fruits;

	// 种水果
	public void fetch() {
		//实例化scanner
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入一种水果(apple banana  grape):");
		String fruit = sc.next();
		
		//面向接口的编程
		IFetchable fetchable=null;
		
		
		if(fruit.equals("apple")) {
			fetchable = new Apple();
		}else if(fruit.equals("banana")) {
			fetchable = new Banana();
		}else if(fruit.equals("grape")) {
			fetchable = new Grape();
		}else {
			System.out.println("输入错误，无法创建");
		}
		
		//用fruit接收fetchable获取的水果名字并进行后续操作
		Fruit fruit1 = fetchable.fetchfruit();
		
		

	}
}
